# -*- coding: utf-8 -*-
"""
与进程有关的信息，可用于守护进程作用
"""

import psutil

# 获取所有进程
all_processes = list(psutil.process_iter())

for proc in all_processes:
    pid, name = proc.pid, proc.name()
    print('%d, %s' %(pid, name))

# 获取进程启动命令行
for proc in all_processes:
    name = proc.name()
    if 'python' not in name:
        continue
    cmd = proc.cmdline()
    print(cmd)